package com.zhixin.zhixinmall.config;

import java.time.LocalDateTime;

import org.apache.ibatis.reflection.MetaObject;
import org.springframework.context.annotation.Configuration;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;

/**
 * @author cyc
 * @date 2023/10/08 15:11:57
 */
@Configuration
public class MyMetaObjectHandler implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        setFieldValByName("registerDate", LocalDateTime.now(), metaObject);
        setFieldValByName("lastLoginDate", LocalDateTime.now(), metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        setFieldValByName("lastLoginDate", LocalDateTime.now(), metaObject);
    }

}
